package com.lee.litepaltest;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

/**
 * @类名: ${type_name}
 * @功能描述:
 * @作者: ${user}
 * @时间: ${date}
 * @最后修改者:
 * @最后修改内容:
 */
public class LitepalAdapter extends BaseAdapter {
    
    private List<Bean> mBeen;
    private Context mContext;
    private LayoutInflater mLayoutInflater;

    public LitepalAdapter(List<Bean> been, Context context) {
        mBeen = been;
        mContext = context;
        mLayoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
       return mBeen.size();   
    }

    @Override
    public Object getItem(int position) {
        return mBeen.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        
        ViewHolder holder = null;
        if (convertView == null){
            convertView = mLayoutInflater.inflate(R.layout.item, parent, false);
            holder = new ViewHolder();
            holder.id = (TextView) convertView.findViewById(R.id.id_edit);
            holder.content = (TextView) convertView.findViewById(R.id.icontent_edit);
            holder.data = (TextView) convertView.findViewById(R.id.data_edit);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        
//        holder.id.setText(mBeen.get(position).getId() + "");
        holder.content.setText(mBeen.get(position).getContent());
        holder.data.setText(String.valueOf(mBeen.get(position).getDate()));
        
        return convertView;
    }

    final class ViewHolder {
        private TextView id;
        private TextView content;
        private TextView data;
    }
    
}
//jhfghfh